var model = require('../models/monthly.server.model');
var menuModel =require('../models/menu.server.model');

module.exports = {
	getMonthlyAll:function(req , res , next){
		var params = req.query || req.param;
		var userObj = req.session.user;
		if(!userObj){
			res.redirect('/login');
			return;
		}
		model.getMonthLyAll(params,function(result){
			var resObject = {code:0,result:result,role:userObj.role};
			menuModel.getMenu({place:5,userId:userObj.user.ROLE_ID},function(result){
				resObject.menu = result;
				model.getRedisArr().getRedisData(resObject,function(object){
					res.send(object);
				});
			});
		});
	},
	addMonthly:function(req , res , next){
		var param = req.body;
		model.addMonthly(param,function(result){
			res.send(result);
		});
	},
	uploadMonthly:function(req , res , next){
		var param = req.body;
		model.uploadMonthly(param,function(result){
			res.send(result);
		});
	},
	removeMonthly:function(req , res, next){
		var param = req.body;
		model.removeMonthly(param,function(result){
			res.send(result);
		});
	}
};